package com.alibaba.org.dto;


import com.alibaba.org.domain.Employee;
import com.alibaba.org.domain.Shop;
import lombok.Data;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import java.util.Date;


/**
 *
 * 店铺入驻的Dto
 *
 * */
@Data
public class ShopSettlementDto {
        // 店铺的字段
//        @NotNull // 用于对象以及 Long Integer
//        @NotEmpty // 用于集合
        @NotBlank(message = "店铺名字不能为空") // 用于字符串
         private String name;
        @NotBlank(message = "店铺电话不能为空")
         private String tel;
        @NotBlank(message = "店铺地址不能为空")
         private String address;
         private String logo;
         // 店长信息字段
        @Valid
         private ShopAdminDto admin;
        // 添加店铺的信息
        public Shop getShop(){
            return Shop.builder()
                    .name(this.name)
                    .address(this.address)
                    .tel(this.tel)
                    .logo(this.logo)
                    .registerTime(new Date())
                    .state(0)
                    .build();
        }
        // 添加员工的信息
        public Employee getEmp(){
            return Employee.builder()
                    .username(this.admin.getUsername())
                    .email(this.admin.getEmail())
                    .state(1)
                    .phone(this.admin.getPhone())
                    .password(this.admin.getPassword())
                    .build();
        }
}
